const defaultState = {
    inputValue: [],
    list: [],
    music: {}
}
export default (state = defaultState, action) => {
    console.log(state, action, '123')
    if (action.type == 'inputValue') {
        console.log(action.value)
        let newState = JSON.parse(JSON.stringify(state))
        console.log(newState)
        newState.inputValue = action.value
        console.log(newState)
        return newState
    }
    if (action.type == 'deleteList') {
        console.log('asdsadsa123', action.value)
        let delState = JSON.parse(JSON.stringify(state))
        console.log(delState)
        delState.list.splice(action.value, 1)
        console.log(delState)
        return delState
    }
    if (action.type == 'songName') {
        console.log('ssss', action.value)
        console.log(state)
        let newState = JSON.parse(JSON.stringify(state))
        newState.inputValue = action.value
        console.log(newState, 'm')
        // let newState = {}
        // newState = action.value
        // newState.inputValue =action.value
        return newState
    }
    if (action.type == 'songList') {
        console.log(action.value, state)
        let newState = JSON.parse(JSON.stringify(state))
        newState.list = action.value
        console.log(newState)
        return newState
    }
    if (action.type == 'music') {
        if(action.value){
            console.log(action.value[0])
        let newState = JSON.parse(JSON.stringify(state))
        newState.music = action.value[0]
        console.log(newState)
        return newState
        }
    }
     if (action.type == 'clearAllIist'){
        console.log('asd');
        console.log(action)
        let newState = JSON.parse(JSON.stringify(state))
        newState.list = action.value
        console.log(newState)
        return newState
    }
    return state
}